How to Display Sale Price End Date in woocommerce

Display Sale Price End Date in woocommerce

To display the sale price end date in WooCommerce, you can add some custom code to your theme’s functions.php file or to a custom plugin. If you are a WordPress/WooCommerce developer then this article is very helpful to you.

How to define Sale Price End Date

Before starting the process, You have to know how to set the sale start and end date in WooCommerce Product. Follow the below steps to define the sale price start and end date:

Create or Edit any product

When you will create a new product or edit your already created product, then you can see the below screenshot image option in the product meta general option. Please refer to the below image

Define Sale Price  start and End Date in woocommerce

Here, You can see the schedule option in the above screenshot.

Now click on the schedule button and refer to the below screenshot image.

schedule Sale Price start and End Date in woocommerce

Now you can add the sale price start date and end date and update the product page.

Suggested Read: How to check if a product is in a WooCommerce order

Display the Sale Price End Date on a Single Product Page

To display the sale price end date below the product summary on the product page in WooCommerce, You can add the below code snippets to your child theme’s functions.php file or create a plugin for it.

This code adds an action to the woocommerce_single_product_summary hook, which is used to display the sale price end date on a single product page. The display_sale_price_end_date function checks if the product is on sale and gets the sale end date from the product’s metadata.

Output:

After product summary Display sale price end date

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Display the Sale Price End Date below the Sale Price

Copy and paste the following code snippet in your child theme’s functions.php file:

This code will add the sale price end date below the sale price on the product page. The date format will be based on the WordPress date format settings.

Output

how to Display sale price end date below the sale price

Display Sale Price End Date after Shop Loop Item

To display the sale price end date after the product price in the shop loop items, You can add the below code to your child theme’s functions.php file or use a plugin like Code Snippets to add it to your site.

The above code adds an action to the woocommerce_after_shop_loop_item_title hook, which is used to display the sale price end date on shop loop items. The display_sale_price_end_date function checks if the product is on sale and gets the sale end date from the product’s metadata.

Output

Display sale price end date after shop loop item title

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Optimized Code to Display the sale price end date

This code will add a new paragraph element below the product price on the shop page and display the sale end date in the format specified by the date_format option in your WordPress settings. If there is no sale end date set for the product, this paragraph element will not be displayed.

Wrapping Words

Thanks for reading 🙏, I hope you found the How to Display the Sale Price End Date after Shop Loop Item or single product page in the woocommerce tutorial helpful for your project. Keep learning! If you face any problems – I am here to solve your problems.

Related posts